package cn.ch.train.common.context;


import cn.ch.train.common.response.MemberLoginResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LoginMemberContext {
    private static final Logger logger = LoggerFactory.getLogger(LoginMemberContext.class);
    private static ThreadLocal<MemberLoginResult> member = new ThreadLocal<>();

    public static MemberLoginResult getMember() {
        return member.get();
    }

    public static void setMember(MemberLoginResult member) {
        LoginMemberContext.member.set(member);
    }

    public static Long getId() {
        try {
            return member.get().getId();
        } catch (Exception e) {
            logger.error("获取登录会员信息异常", e);
            throw e;
        }
    }
}
